home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: philma@ix.netcom.com(Phil Majtan)
- Newsgroups: comp.lang.c
- Subject: Re: What is wrong with this loop?
- Date: 20 Apr 1996 22:27:41 GMT
- Organization: Netcom
- Message-ID: <4lboct$nni@dfw-ixnews3.ix.netcom.com>
- References: <4l86la$1t9@uwm.edu>
- NNTP-Posting-Host: det-mi4-10.ix.netcom.com
- X-NETCOM-Date: Sat Apr 20 5:27:41 PM CDT 1996
-
- In <4l86la$1t9@uwm.edu> mardavuy@alpha2.csd.uwm.edu (Mario David Uy)
- writes:
- >
- >#include <stdio.h>
- >int main(void)
- >{
- > int dia;
- >
- > char cd;
- >
- > ...
- >
- > scanf("%c", &cd);
- > while (cd != 'm' || cd ! 'f' || cd != 'o')
- > {
- > printf("Re-enter m, f, or o.\n");
- > scanf(%c", &cd);
- > }
- > ...
- >}
- >
- >It works fine, except that it gives me the printf() twice.
- >
-
- I think you might need to re-examine the logic. As far as I remember
- in logic class, having three negative or's like that will always be
- true. What you probably need is !=g && !=f && !=o or something like
- that, because they ALL have to be true to not ask for input again. You
- see?
- Phil
-
-